home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 49 / Amiga Format CD49 (2000-01-17)(Future Publishing)(GB)(Track 1 of 3)[!][issue 2000-02].iso / -serious- / graphics / amicad / arexx_english / importtext.amicad < prev    next >
Text File  |  1999-12-06  |  2KB  |  80 lines

  1. /* Import a text in a box */
  2. /* $VER: ImportText 1.02e (© R.Florac, 22 mai 1999) */
  3.  
  4. options results
  5.  
  6. signal on error
  7. signal on syntax
  8.  
  9. 'FIRSTSEL'; obj=result
  10. if obj>0 then do
  11.     'TYPE('obj')'
  12.     if result=22 then do
  13.     'NEXTSEL('obj')'
  14.     if result=0 then do
  15.         'COORDS('obj')';
  16.         PARSE VAR result x0 ',' y0 ',' x1 ',' y1
  17.         xg=minima(x0,x1); xd=maxima(x0,x1)
  18.         yh=minima(y0,y1); yb=maxima(y0,y1)
  19.         'REQFILE("Name of the text file?", "Work:text/ASCII")'; fichier=result
  20.         y0=yh
  21.         if fichier ~= "" then do
  22.         if open(file, fichier, 'R') then do
  23.             y0=y0+10
  24.             'SAVEALL(-1)'
  25.             do while y0 < y1
  26.             ligne=readln(file)
  27.             if ligne ~= "" then do
  28.                 ligne=translate(ligne,"        ",'09'x)
  29.                 'WRITE("'doublage_guillemets(ligne)'",'xg','y0')'; e=result
  30.                 if e=0 then do
  31.                 'REQUEST("Text placement in line"+CHR(10)+"'ligne'"+CHR(10)+"impossible."+CHR(10)+"Do you want to continue?")'
  32.                 if result=0 then leave
  33.                 end
  34.                 y0=y0+10
  35.             end
  36.             if eof(file) then leave
  37.             end
  38.             close(file)
  39.         end
  40.         end
  41.         exit
  42.     end
  43.     end
  44. end
  45.  
  46. 'MESSAGE("Draw and select a box"+CHR(10)+"where you want to"+CHR(10)+"put the text")'
  47.  
  48. exit
  49.  
  50. minima: procedure
  51.     parse arg v1,v2
  52.     if v1<v2 then return v1
  53.     return v2
  54. end
  55.  
  56. maxima: procedure
  57.     parse arg v1,v2
  58.     if v1>v2 then return v1
  59.     return v2
  60. end
  61.  
  62. doublage_guillemets: procedure
  63.     parse arg chaine
  64.     t=''
  65.     do i=1 to length(chaine)
  66.     c = substr(chaine,i,1)
  67.     if c='"' then c=c||'"'
  68.     t=t||c
  69.     end
  70.     return t
  71.  
  72. syntax:
  73. erreur=RC
  74. 'MESSAGE("Script ImportText.AmiCAD"+CHR(10)+"Syntax error"+CHR(10)+"in line 'SIGL'"+CHR(10)+"'errortext(erreur)'")'
  75. exit
  76.  
  77. error:
  78. 'MESSAGE("Script ImportText.AmiCAD"+CHR(10)+"Error in line 'SIGL'")'
  79. exit
  80.